package ru.gerunn.test.thread;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

public class MyQueue<T> {

	private static final Object monitor = new Object();

	private Queue<T> queue;

	public MyQueue() {
		this.queue = new ConcurrentLinkedQueue<T>();
	}

	public void add(T t) {
		synchronized (MyQueue.monitor) {
			this.queue.add(t);
			monitor.notifyAll();
		}
	}

	public T get() throws InterruptedException {
		synchronized (MyQueue.monitor) {
			return this.queue.poll();
		}
	}

}
